<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>客户管理</title>
	<meta name="decorator" content="default"/>
</head>
<body>
	<div data-role="navbar">
		<ul>
			<li><a href="${ctx}/base/customer/detail?id=${customerId}&emsId=${emsId}">客户基本资料</a></li>
			<li><a href="${ctx}/expert/customerExam/list">专家方案</a></li>
			<li><a href="${ctx}/base/customer/cards">客户卡信息</a></li>
			<li><a href="#" class="ui-btn-active">客户消费记录</a></li>
		</ul>
	</div>
	<form:form id="searchForm" modelAttribute="" action="${ctx}/base/customer/consume" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	</form:form>
	<div  class="form-input">
	<tags:message content="${message}"/>
	<c:set var="emsId" scope="session" value="${emsId}"></c:set>
	<c:set var="customerId" scope="session" value="${customerId}"></c:set>
	<div class="icon-buttons">
		<a id="returnBtn" class="leave-detail" data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="#">返 回</a>
	</div>
	<br/>
	<h3 class="middleCls">消费记录列表</h3>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead>
			<tr>
				<th>流水号</th>
				<th>消费时间</th>
				<th>是否确认</th>
			</tr>
		</thead>
		<tbody>
		<c:if test="${empty page.list}">
			<tr>
				<td colspan="3">无记录</td>
			</tr>
		</c:if>
		<c:if test="${not empty page.list}">
			<c:forEach items="${page.list}" var="storeConsume">
				<tr id="${storeConsume.id}">
					<td>${storeConsume.consume_Number}</td>
					<td>
						${fns:formatDate(storeConsume.consume_Time, "yyyy-MM-dd")}
					</td>
					<td>
						<c:if test="${storeConsume.confirmed == 0}">未确认</c:if>
						<c:if test="${storeConsume.confirmed == 1}">已确认</c:if>
					</td>
				</tr>
			</c:forEach>
		</c:if>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#contentTable tbody tr").click(function(){
				if (!this.id){
					return;
				}
				$("#contentTable tbody tr").removeClass("select_active");
				$(this).addClass("select_active");
				window.location.href="${ctx}/base/customer/consumeDetail?consumeId=" + this.id;
			});
			//离开本模块时,清除使用过的session
			$(".leave-detail").click(function(){
				sessionStorage.removeItem("target");
				var target = this.href;
				var url = "${ctx}/cleanSession?sessionKeys=emsId,customerId";
				var backFun = function(){
					window.location.href = target;
		 		};
		 		syncToServer(url, backFun);
				return false;
			});
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				},
				messages: {
					email:"格式有误！"
					}
			});
			initCustomerDetailReturnButton("${ctx}", "${emsId}", "${customerId}");
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</body>
</html>
